using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace DungeonOfDespair
{
    public class GameStateTitle
        : GameState
    {
        private GameStateType m_gameStateTypeNext;
        private bool m_bOptionPlay;

        public GameStateTitle()
        {
            m_gameStateTypeNext = GameStateType.None;
            m_bOptionPlay = true;
        }

        public void OnKeyDown(object objectSender, KeyEventArgs keyEventArgs)
        {
        }

        public void OnKeyUp(object objectSender, KeyEventArgs keyEventArgs)
        {
            switch (keyEventArgs.KeyCode)
            {
                case Keys.Up:
                case Keys.Down:
                    m_bOptionPlay = !m_bOptionPlay;
                    break;
                case Keys.Space:
                case Keys.Return:
                    if (m_bOptionPlay)
                        m_gameStateTypeNext = GameStateType.Loading;
                    else
                        Application.Exit();
                    break;
            }
        }

        public void Update()
        {
        }

        public void Draw(Graphics graphics)
        {
            Image imageTitle = Properties.Resources.Title;
            graphics.DrawImage(imageTitle, 0, 0, imageTitle.Width, imageTitle.Height);

            Image imagePlay = Properties.Resources.TitlePlay;
            Image imageExit = Properties.Resources.TitleExit;

            if (m_bOptionPlay)
                graphics.DrawImage(imagePlay, 286, 278, imagePlay.Width, imagePlay.Height);
            else
                graphics.DrawImage(imageExit, 286, 329, imageExit.Width, imageExit.Height);
        }

        public GameStateType NextState
        {
            get { return m_gameStateTypeNext; }
        }
    }
}
